﻿package cocoaas3.flash{
	import jp.progression.casts.*;
	import jp.progression.commands.display.*;
	import jp.progression.commands.lists.*;
	import jp.progression.commands.managers.*;
	import jp.progression.commands.media.*;
	import jp.progression.commands.net.*;
	import jp.progression.commands.tweens.*;
	import jp.progression.commands.*;
	import jp.progression.data.*;
	import jp.progression.events.*;
	import jp.progression.scenes.*;
	import flash.events.*;
	import flash.display.*;
	import flash.geom.*;
	import flash.text.*;
	import caurina.transitions.Tweener;


	public class UITableViewCell extends UIView{

		//
		// original member
		//
		public var backgroundView:Sprite = new Sprite();
		private var _contentView:Sprite = new Sprite();
		private var _textLabel:TextField = new TextField();
		private var _reuseIdentifier:String;

		public function get contentView():Sprite{ return _contentView; };// こいつにmcをaddChildする
		public function get textLabel():TextField{ return _textLabel; };
		public function get reuseIdentifier():String{ return _reuseIdentifier; };

		//
		// custom member
		//


		public function UITableViewCell( $reuseIdentifier:String ){
			//Console.log( "UITableViewCell constructor" );
			_reuseIdentifier = $reuseIdentifier;

			//addChild( backgroundView );
			//addChild( _contentView );
			//addChild( _textLabel );

			//this.mouseChildren = false;

			this.addEventListener( MouseEvent.MOUSE_DOWN, _onMouseDown );
			this.addEventListener( MouseEvent.MOUSE_UP, _onMouseUp );
			this.addEventListener( MouseEvent.MOUSE_OUT, _onMouseUp );

		}

		override function onAddedToStage( e:Event ):void {
			//trace( "UITableViewCell onAddedToStage" );
		}
		override function onRemovedFromStage( e:Event ):void {
			//trace( "UITableViewCell onRemovedFromStage" );
		}

		//
		// original methods
		//
		public function setHighlighted( highlighted:Boolean, animated:Boolean=true ):void{
			if( highlighted ){
				new DoTweener( backgroundView, {_color_redMultiplier:0.2, _color_greenMultiplier:0.2, time:0, delay:0.1} ).execute();
			} else {
				Tweener.removeTweens( backgroundView );
				new DoTweener( backgroundView, {_color_redMultiplier:1, _color_greenMultiplier:1, time:0} ).execute();
			}
		}

		// テーブルビューのデリゲートによって再利用するために再利用可能なセルを用意する。
		public function prepareForReuse():void{
		}





		//
		// custom methods
		//
		private function _onMouseDown(e){
			setHighlighted( true );
		}
		private function _onMouseUp(e){
			setHighlighted( false );
		}




	}

}

